package collection2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class 集合转换成数组 {
    public static void main(String[] args) {

        Collection c=new ArrayList<>();
        c.add("789");
        c.add(78.5);
        c.add(7);
        c.add("wo");

        Object[] obj = c.toArray(new Object[c.size()]);


        System.out.println(Arrays.toString(obj));
        System.out.println(obj.length);



        Collection<String> c3=new ArrayList<>();
        c3.add("78.9");
        c3.add("7");
        c3.add("wo");
        c3.add("和");

        String[] strings = c3.toArray(new String[c3.size()]);
        System.out.println(strings.length);//String数组的长度



    }
}
